/**
 * Created by wenchuan on 2018/03/02.
 */
var debug = true;
var js_verison = '1.2';
var js_verison_ = js_verison;

var appOps = {
    debug: debug,
    html_version: js_verison_,
    css_version: '1.0',
    appName: 'CRM',
    baseUrl_prefix: ''
};

var doc = document, win = window;
var isPrd = false;//是否正式环境

(function (gw, dom, require) {

    var pathname = location.pathname;
    var firsthPathname = pathname.split('/')[1];
    var staticPath = location.origin + '/' + firsthPathname + '/';

    if (firsthPathname == 'qscrmprd') {
        isPrd = true;
    }


    if (!debug && gw.navigator.userAgent.toLowerCase().match(/MicroMessenger/i) != 'micromessenger') {
        gw.history.back(10);
        return true;
    }

    require.config({
        baseUrl: staticPath + 'js/wx',
        waitSeconds: 0,
        scriptType: 'text/javascript',
        urlArgs: function (id, url) {
            var _v = js_verison;
            switch (id.split('/')[0]) {
                case 'app':
                case 'public':
                    _v = js_verison_;
                    break;
            }
            return (url.indexOf('?') === -1 ? '?' : '&') + 'v=' + _v;
        },
        paths: {
            'app': 'app',
            'public': 'public',
            'mui': 'libs/mui.min',
            'muipreviewimageNew': 'libs/mui.previewimageNew',
            'muipicker': 'libs/mui.picker',
            'muipoppicker': 'libs/mui.poppicker',
            'vue': 'libs/vue.min',
            'zepto': 'libs/zepto.min',
            'jweixin': 'libs/jweixin-1.2.1',
            'echarts': 'libs/echarts-all',
            'signature_pad': 'libs/signature_pad.min',
            'wx-iconfont': 'public/wx-iconfont.min',
            'webview': 'public/webview'
        }
    });

    if (parent.app) {
        gw.app = parent.app;
        app.flexible.init(gw);
        app.initSys(gw);
        app.hideMenus();
        gw.Vue = parent.require('vue');
    }

    require(["zepto", "mui"], function ($, mui) {

        if (pageConfig && pageConfig.jss) {
            require(pageConfig.jss, pageConfig.cb || $.noop);
        }

    });

})(win, doc, require);